/**
 *  Private Calendar allows you to add private calendars to Android's
 *  Calendar Storage.
 *  Copyright (C) 2012  Harald Seltner <h.seltner@gmx.at>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package at.seltner.colorpicker;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

public class ColorPickerDialog extends Dialog {

	private int initialColor;
	private OnColorChoosenListener onColorChoosenListener;
	private OnColorCancelListener onColorCancelListener;
	private String title;
	

	public ColorPickerDialog(Context context, int initialColor, String title,
			OnColorChoosenListener choosen, OnColorCancelListener cancel) {
		super(context);
		this.initialColor = initialColor;
		onColorChoosenListener = choosen;
		onColorCancelListener = cancel;
		this.title = title;
	}
	
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		
		OnColorChoosenListener choosen = new OnColorChoosenListener() {
			@Override
			public void colorChoosen(int color) {
				onColorChoosenListener.colorChoosen(color);
				ColorPickerDialog.this.dismiss();
			}
		};

		OnColorCancelListener cancel = new OnColorCancelListener() {
			@Override
			public void colorCancel(int initialColor) {
				onColorCancelListener.colorCancel(initialColor);
				ColorPickerDialog.this.dismiss();
			}
		};

        setContentView(new ColorPickerView(getContext(), initialColor,
        		choosen, cancel));
        setTitle(title);
    }

}
